From f67b5ead2907df7828ab87144d403a376d4dd4e3 Mon Sep 17 00:00:00 2001 From: Christian Limpach Date: Fri, 2 Mar 2007 11:25:12 +0000 Subject: [PATCH] [xenstored] Fix error path when xc_map_foreign_range fails. If xc_map_foreign_range fails, the new domain object is freed, but it is not removed from the connection list. Signed-off-by: Christian Limpach --- tools/xenstore/xenstored_domain.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c index 5249ef6d56..f59ec31d56 100644 --- a/tools/xenstore/xenstored_domain.c +++ b/tools/xenstore/xenstored_domain.c @@ -320,6 +320,7 @@ void do_introduce(struct connection *conn, struct buffered_data *in) unsigned long mfn; evtchn_port_t port; int rc; + struct xenstore_domain_interface *interface; if (get_strings(in, vec, ARRAY_SIZE(vec)) < ARRAY_SIZE(vec)) { send_error(conn, EINVAL); @@ -344,19 +345,21 @@ void do_introduce(struct connection *conn, struct buffered_data *in) domain = find_domain_by_domid(domid); if (domain == NULL) { - /* Hang domain off "in" until we're finished. */ - domain = new_domain(in, domid, port); - if (!domain) { + interface = xc_map_foreign_range( + *xc_handle, domid, + getpagesize(), PROT_READ|PROT_WRITE, mfn); + if (!interface) { send_error(conn, errno); return; } - domain->interface = xc_map_foreign_range( - *xc_handle, domid, - getpagesize(), PROT_READ|PROT_WRITE, mfn); - if (!domain->interface) { + /* Hang domain off "in" until we're finished. */ + domain = new_domain(in, domid, port); + if (!domain) { + munmap(interface, getpagesize()); send_error(conn, errno); return; } + domain->interface = interface; domain->mfn = mfn; /* Now domain belongs to its connection. */ -- 2.30.2